LinkField is a RealBasic class based on EditField. It essentially does two things: lets you know when the user has clicked on an URL in your field, and marks the URLs with underline and (by default) blue color - including when the text changes. In addition, LinkField can, if you so desire, let the user select words just by clicking on them.
Using LinkField
LinkField is very easy to use. In most respects, it behaves just as any normal EditField. The only differences is that URLs are marked, and when the user clicks on text that is interpreted as a URL, a LinkClick event is fired, with the URL clicked on sent as a parameter. Typically you would have the user's web browser go to that URL, with the showURL method in Applet windows.
Note: LinkField EditFields must have the Styled property set. Also, if you want the LinkClick events to be fired, it can not be ReadOnly.
There are only two methods and one property in addition to the normal EditField methods and properties:
setHighlightColor(c as Color)
sets the color links are shown in.
addProtocol(protocol as string)
adds a new protocol. By default, LinkFields understand http://, https://, ftp://, mailto:, hotline://, and telnet://. Normally you would use this method in the Open event.
Finally, you can have the LinkField select any word clicked on, not just links, with:
highlightWords = true
This property is false by default.
LinkField is freeware for personal use - enjoy!
If you plan on using LinkField for commercial/shareware, please email me so we can arrange something.
Contact info:
Stefan Möller
SpectroGrafx Productions
stefan@spectrografx.com
http://www.spectrografx.com
* I can often be found at the RB cafe, hotline://cafe.realbasic.com. My nickname, "Stefan", usually gives me away.